home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / cross / sasmv14.dms / sasmv14.adf / examples / recmacro.s < prev    next >
Text File  |  1993-05-22  |  673b  |  33 lines

  1.  
  2. *************************************************
  3. **
  4. ** This MACRO will calculate the FAKULTÄT of arg
  5. ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. ** (dont know the english word for this german
  7. **  goodie)
  8. **
  9. ** © 1993 by FWS - SASM
  10. **
  11. *************************************************
  12.  
  13.     heap    O=128
  14.  
  15. arg    set    12        ;thats the input
  16. result    set    1
  17.  
  18. fak    macro
  19.     if \1#1
  20. result        set    result*\1
  21. \1        set    \1-1
  22.     fak    \1            ;recursive descent...
  23.     endc
  24.     endm
  25.  
  26.     fak    arg            ;the parameter of fak is a set symbol!
  27.     .say    The result is:
  28.     exp=    result
  29.  
  30. ;by the way: arg=12 is the maximum input, anything higher
  31. ;will cause the 32bit signed math routines of SASM to over-
  32. ;flow... too bad... :)
  33.